import { CommonModel, ListResponse, PagerQuery } from '.'
import { authorizeRequest } from '../util/http'

const ROUTER = '/v1/pictures'

type GetPictureListParams = PagerQuery & {
    categoryId:number
}
export type PictureListResponse = ListResponse<Picture>
export interface Picture extends CommonModel{
    title:string;
    imageUrl:string;
    desc:string;
    public:boolean;
    userId:number;
    categoryId:number;
}
export const apiGetPictureList = async (params:GetPictureListParams)=>{
    return (await authorizeRequest.get<PictureListResponse>(ROUTER,{params})).data
}
export interface CreatePictureParmas{
    title:string;
    imageUrl:string;
    categoryId:number;
    desc:string;
    public:boolean;
}

export const apiCreatePicture = async (params:CreatePictureParmas) =>{
    return (await authorizeRequest.post(ROUTER,params)).data
}